package com.example.bomc.dao;


import com.example.bomc.model.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserDAO {
    String TABLE_NAME = "user";
    String INSET_FIELDS = " username, password, salt, isCapacity ,isExamined";
    String SELECT_FIELDS = " id, name, password, salt ";

    @Insert({"insert into ", TABLE_NAME, "(", INSET_FIELDS,
            ") values (#{username},#{password},#{salt},#{isCapacity},#{isExamined})"})
    int addUser(User user);

    @Select({"select ", SELECT_FIELDS, " from ", TABLE_NAME, " where name=#{name}"})
    User selectByName(String name);

    @Select("select * from user where username = #{username}")
    /*@Results({
            @Result(id = true, property = "id", column = "id"),
            @Result(property = "roles", column = "rid", javaType = List.class, many = @Many(select = "com.example.bomc.dao.RoleDao.findByUid"))
    })*/
    User findByName(String username);


}
